/**
 * 
 */
package org.dkbrazz.sparkplug;

import java.awt.Component;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.swing.JLabel;

import org.jivesoftware.smackx.packet.VCard;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.ui.*;
import org.jivesoftware.spark.ui.ChatRoom.ChatToolBar;
import org.jivesoftware.spark.ui.rooms.ChatRoomImpl;
import org.jivesoftware.spark.util.ModelUtil;

/**
 * @author Denis Kurochkin
 *
 */
public class ToolbarExtChatRoomListener implements ChatRoomListener{

	@Override
	public void chatRoomActivated(ChatRoom arg0) {
	}

	@Override
	public void chatRoomClosed(ChatRoom arg0) {
	}

	@Override
	public void chatRoomLeft(ChatRoom arg0) {
	}

	@Override
	public void chatRoomOpened(ChatRoom chatRoom) {
		
		if (chatRoom instanceof ChatRoomImpl)
		{
			ChatRoomImpl room = (ChatRoomImpl)chatRoom;
			ChatToolBar toolBar = chatRoom.getToolBar();
			for (Component comp : toolBar.getComponents())
			{
				if (comp instanceof VCardPanel) 
				{
					VCardPanelExt vcardPanelExt = new VCardPanelExt(room.getParticipantJID());
					toolBar.remove(comp);
					toolBar.add(vcardPanelExt, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 2), 0, 0));
				}
			}
		}
	}
	
	@Override
	public void userHasJoined(ChatRoom arg0, String arg1) {
	}

	@Override
	public void userHasLeft(ChatRoom arg0, String arg1) {
	}

}
